<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ToSQL 方法</title>
<style type="text/css">
<!--
body { margin:0 auto; font-size:12px; line-height:150%; font-family:Verdana, Arial, Helvetica, sans-serif;}
a:link, a:active, a:visited {color: #0000FF;text-decoration: underline;}
a:hover {color: #0066FF;text-decoration: underline;}
ul, li { margin:0; padding:0; list-style:none; display:inline;}

	#header { width:100%; background-color:#9CF; border-bottom:1px solid #999;}
		#header .headertxt { padding:5px;}
	
	#main { width:96%; margin:0 auto; margin-top:20px;}
		#main #name { font-size:16px; color:#03F; border-bottom:2px solid #03F; padding-bottom:5px; margin-bottom:10px;}
		#main #content { font-size:14px; margin-bottom:20px;}
		#main .title, #footer .title { font-size:12px; font-weight:bold; color:#03F; }
		#main .code { padding:5px 30px;}
		#main .codem { color:#F60;}
		#main .codeparam { color:#666; font-style:italic;}
		#main .codetitle { color:#666; font-style:italic; width:1px;}
		#main .codetype { color:#666; font-style:italic;}
		#main .codenote { }
		#main .codeerror { color:#900;}
		#main td {padding:3px;}
	
	#footer { width:96%; margin:0 auto; margin-top:10px;}
		#footer .nav { padding:5px 0; border-bottom:1px solid #999;}
		#footer .mail { padding:5px 0;}
		#footer .copyright { }
	
	/** NORMAL CODE HIGHLIGHT **/
	#normal { border:1px solid #ccc;}
	#normal .hcode { font-family: Courier New, Courier, monospace; line-height:19px; }
	#normal .hline { color:#333; font-style:italic; background-color:#ccc; border-right:3px solid #0C0; margin-right:8px; padding:2px 10px;}
	#normal .hacl { color:#F60;}
	#normal .hver { color:#00F;}
	#normal .hconst { color:#099;}
	#normal .hparam { color:#060;}
	#normal .hnumber { color:#F00;}
	#normal .hfunction { color:#906;}
	#normal .hnote { color:#999;}
	#normal .hresult { background-color:#000; color:#1dc116;}
	
	/** FADETOGREY HIGHLIGHT **/
	#fadetogrey { border:1px solid #000;}
	#fadetogrey .hcode { font-family: Courier New, Courier, monospace; line-height:19px; background-color:#121212; color:#FFF;}
	#fadetogrey .hline { color:#afafaf; font-style:italic;border-right:3px solid #36C; margin-right:8px; padding:2px 10px;}
	#fadetogrey .hacl { color:#F60;}
	#fadetogrey .hver { color:#d01d33;}
	#fadetogrey .hparam { color:#e3e658;}
	#fadetogrey .hnumber { color:#F00;}
	#fadetogrey .hfunction { color:#906;}
	#fadetogrey .hnote { color:#696854;}
-->
</style>
</head>

<body>
<div id="header"><div class="headertxt">Boyle.ACL 类库文档 (VBScript)</div></div>
<div id="main">
	<div id="name">System.Data.ToSQL 方法</div>
    <div id="content">根据指定条件生成SQL查询语句</div>
	<div id="method">
   	  <div class="title">语法</div>
        <div class="code"><span class="codem">System.Data.ToSQL</span>(<span class="codeparam">Collection</span>, <span class="codeparam">Condition</span>, <span class="codeparam">Order</span>)</div>
    </div>
	<div id="param">
    	<div class="title">参数</div>
        <div class="code">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="80" class="codetitle">Collection</td>
              <td class="codetype">Array(数组)</td>
            </tr>
            <tr>
              <td class="codetitle">&nbsp;</td>
              <td class="codenote">必选项，不能为空。包括表，字段以及取的记录数。格式必须遵守 <span class="codeerror">Array(&quot;表名&quot;, &quot;字段名1,字段名2...&quot;, &quot;数量&quot;)</span>的形式。</td>
            </tr>
            <tr>
              <td class="codetitle">Condition</td>
              <td class="codetype">String(字符串) 或 Array(数组)</td>
            </tr>
            <tr>
              <td class="codetitle">&nbsp;</td>
              <td class="codenote">必选项，可以为空。查询的条件。可以直接写条件语句。如果将多个条件用AND进行连接的话，也可以写成数组形式。格式必须遵守 <span class="codeerror">Array(字段1=值1, 字段2>值2, ...)</span> 的形式。</td>
            </tr>
            <tr>
              <td class="codetitle">Order</td>
              <td class="codetype">String(字符串)</td>
            </tr>
            <tr>
              <td class="codetitle">&nbsp;</td>
              <td class="codenote">必选项，可以为空。排序的方式。</td>
            </tr>
          </table>
      </div>
    </div>
	<div id="return">
    	<div class="title">返回值</div>
        <div class="code"><span class="codetype">String(字符串)</span></div>
    </div>
	<div id="notes">
    	<div class="title">注释</div>
        <div class="code">无</div>
    </div>
	<div id="sample">
    	<div class="title">示例</div>
        <div class="code">
       	  <div id="normal">
           	  	<div class="hcode"><span class="hline">&nbsp;1.</span><span class="hver">With</span> <span class="hacl">System.Data</span></div>
   	  	  	  <div class="hcode"><span class="hline">&nbsp;2.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hver">Dim</span> strSQL1, strSQL2, strSQL3, strSQL4</div>
                <div class="hcode"><span class="hline">&nbsp;3.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hnote">'// 取出USER表中包括全部字段的所有记录</span></div>
                <div class="hcode"><span class="hline">&nbsp;4.</span>&nbsp;&nbsp;&nbsp;&nbsp;strSQL1 = <span class="hacl">.ToSQL</span>(<span class="hver">Array</span>(<span class="hparam">&quot;USER&quot;</span>, <span class="hparam">&quot;&quot;</span>, <span class="hparam">&quot;&quot;</span>), <span class="hparam">&quot;&quot;</span>, <span class="hparam">&quot;&quot;</span>)</div>
                <div class="hcode"><span class="hline">&nbsp;5.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hnote">'// 取出USER表中包括ID,NAME,PASS三个字段，条件为NAME等于Boyle或PASS等于123456的所有记录</span></div>
                <div class="hcode"><span class="hline">&nbsp;6.</span>&nbsp;&nbsp;&nbsp;&nbsp;strSQL2 = <span class="hacl">.ToSQL</span>(<span class="hver">Array</span>(<span class="hparam">&quot;USER&quot;</span>, <span class="hparam">&quot;ID,NAME,PASS&quot;</span>, <span class="hnumber">0</span>), <span class="hparam">&quot;NAME='Boyle' Or PASS='123456'&quot;</span>, <span class="hparam">&quot;&quot;</span>)</div>
              	<div class="hcode"><span class="hline">&nbsp;7.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hnote">'// 取出USER表中包括ID,NAME两个字段，并对ID列进行倒序排序之后的前5条记录</span></div>
                <div class="hcode"><span class="hline">&nbsp;8.</span>&nbsp;&nbsp;&nbsp;&nbsp;strSQL3 = <span class="hacl">.ToSQL</span>(<span class="hver">Array</span>(<span class="hparam">&quot;USER&quot;</span>, <span class="hparam">&quot;ID,NAME&quot;</span>, <span class="hnumber">5</span>), <span class="hparam">&quot;&quot;</span>, <span class="hparam">&quot;ID DESC&quot;</span>)</div>
                <div class="hcode"><span class="hline">&nbsp;9.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hnote">'// 取出USER表中包括全部字段，条件为NAME列不为空并密码为123456时，并对ID列进行倒序排序之后的前5条记录</span></div>
                <div class="hcode"><span class="hline">10.</span>&nbsp;&nbsp;&nbsp;&nbsp;strSQL4 = <span class="hacl">.ToSQL</span>(<span class="hver">Array</span>(<span class="hparam">&quot;USER&quot;</span>, <span class="hparam">&quot;&quot;</span>, <span class="hnumber">5</span>), <span class="hver">Array</span>(<span class="hparam">&quot;[NAME]&lt;&gt;''&quot;</span>, <span class="hparam">&quot;PASS='123456'&quot;</span>), <span class="hparam">&quot;[ID] DESC&quot;</span>)</div>
   	 	  	  <div class="hcode"><span class="hline">11.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hnote">'// 输出SQL语句</span></div>
                <div class="hcode"><span class="hline">12.</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hacl">System.W</span> strSQL1 <span class="hver">&amp;</span> strSQL2 <span class="hver">&amp;</span> strSQL3 <span class="hver">&amp;</span> <span class="hconst">vbCrLf</span> <span class="hver">&amp;</span> strSQL4</div>
           	  	<div class="hcode"><span class="hline">13.</span><span class="hver">End With</span></div>
                 	<div class="hcode hresult"><span class="hline">14.</span>'// 最终输出结果：</div>
            	<div class="hcode hresult"><span class="hline">15.</span>strSQL1 = Select * From [USER]</div>
                <div class="hcode hresult"><span class="hline">16.</span>strSQL2 = Select [ID],[NAME],[PASS] From [USER] Where NAME='Boyle' Or PASS='123456'</div>
            	<div class="hcode hresult"><span class="hline">17.</span>strSQL3 = Select Top 5 [ID],[NAME] From [USER] Order By ID DESC</div>
            	<div class="hcode hresult"><span class="hline">18.</span>strSQL4 = Select Top 5 * From [USER] Where [NAME]&lt;&gt;'' AND PASS='123456' Order By [ID] DESC</div>
       	  </div>
    	</div>
    </div>
</div>
<div id="footer">
  <div class="title">请参见</div>
	<div class="nav"><a href="index.html">System.Data类</a>&nbsp;|&nbsp;<a href="../index.html">System.Common基类</a></div>
	<div class="mail"><a href="mailto:boyle7@qq.com">发送有关此主题的意见</a></div>
    <div class="copyright">Boyle.ACL v4.0.121028 类库文档. Copyright (C) 2006-2012 Boyle.</div>
</div>

</body>
</html>
